<template>
<div class="tab">
  <div class="u-title-index">
    <div class="before" :style="beforeColor"></div>
    <h2 id="J-floor-title1" :style="H2Color">
      <svg-icon icon-class="dianya" class-name="dianya" />
      <em>{{goods.name}}</em>
    </h2>
  </div>
  <div class="J-floor m-floor-wrapper active show autoplayed">
    <div class="m-floor-index swiper-container stopTimeout">
      <div class="hd">
        <div class="pagination">
          <span class="swiper-pagination-switch" v-bind:class="{ setClassActive:setClass && index=== current}" v-for="(item, index) in Object.values(goods.brands)" :key="index" @mouseover="slideTo(index)"  @mouseleave="onMouseOut(index)">{{item.name}}</span>
        </div>
      </div>
      <swiper ref="mySwiper" :options="swiperOptions">
        <swiper-slide  v-for="item in goods.brands" :key="item.id" :label="item.name" :name="'name_' +item.id">
          <goods-card :content="item" :goods="goods" />
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</div>
</template>

<script>
import GoodsCard from '@/components/GoodsCard.vue'
// import { goods } from '@/utils/goods.js'
export default {
  name: 'TabContent',
  components: {
    GoodsCard
  },
  props: {
    beforeColor: {
      background: '#e9f2f2',
      type: String
    },
    H2Color: {
      background: '#4448f8',
      type: String
    },
    goods: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      setClass: false,
      qwerqwre: '',
      current: 0,
      swiperOptions: {
        pagination: {
        }
      }
    }
  },
  computed: {
    swiper () {
      return this.$refs.mySwiper.$swiper
    }
  },
  created () {
  },
  methods: {
    slideTo (index) {
      this.setClass = true
      this.current = index
      this.swiper.slideTo(index, 1000, false)
    },
    onMouseOut (index) {
      console.log(index)
    }
  }
}
</script>
<style lang="scss" scoped>
.tab {
  margin-top: 40px;
}
.u-title-index {
  position: relative;
  margin-top: 80px;
  .before {
    position: absolute;
    content: '';
    width: 100%;
    height: 32px;
    left: 0;
    top: 50%;
    margin-top: -16px;
    border-radius: 20px;
    background: #e9f2f2;
  }
  h2 {
    display: inline-block;
    position: absolute;
    height: 45px;
    line-height: 45px;
    font-size: 22px;
    color: #fff;
    padding: 0 78px 0 60px;
    vertical-align: middle;
    border-radius: 14px;
    box-sizing: border-box;
    background: #4448f8;
    top: -22px;
    left: 0;
    z-index: 1;
    .svg-icon {
      display: inline-block;
      font-size: 18px;
      margin: 0 16px 0 0;
      vertical-align: 0;
    }
  }
}
//商品专区 tab分类
.m-floor-wrapper {
  position: relative;
  height: 646px;
  top: 35px;
}
.m-floor-index {
  margin: 12px 0 0;
  .hd {
    position: relative;
    height: 46px;
    overflow: hidden;
    z-index: 1;
    [class^="pagination"] {
      height: 48px;
      width: auto;
      position: relative;
      text-align: left;
      box-sizing: border-box;
      bottom: 0;
      z-index: 0;
      .swiper-pagination-switch:hover {
        color: #4448f8;
      }
      .setClassActive:after {
        position: absolute;
        content: '';
        width: 100%;
        width: calc(100% - 12px);
        height: 2px;
        left: 6px;
        bottom: 9px;
        background: #4448f8;
      }
      .swiper-pagination-switch {
        cursor: pointer;
        position: relative;
        display: inline-block;
        width: auto;
        height: auto;
        background: none;
        color: #777777;
        padding: 16px 6px 14px;
        margin: 0 14px 0 0;
        border-radius: 4px;
        font-size: 16px;
        opacity: 1;
      }
    }
  }
}
.swiper-container {
  width: 100%;
  height: 100%;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  overflow: hidden;
  direction: ltr;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  backface-visibility: hidden;
  z-index: 1;
}
.el-tabs__nav-scroll {
  overflow: hidden;
  height: 46px;
}
.el-tabs__item {
  font-size: 16px !important;
}
.m-floor-index [class^="pagination"] {
    height: 48px;
    width: auto;
    position: relative;
    text-align: left;
    box-sizing: border-box;
    bottom: 0;
    z-index: 0;
}
.swiper-pagination-switch {
  cursor: pointer;
  position: relative;
  display: inline-block;
  width: auto;
  height: auto;
  background: none;
  color: #777777;
  padding: 16px 6px 14px;
  margin: 0 14px 0 0;
  border-radius: 4px;
  font-size: 16px;
  opacity: 1;
}
</style>
